package com.ruoyi.tsjData.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.pad.ChartLineDTO;
import com.ruoyi.tsjData.domain.plat.DataTshjZhd;
import com.ruoyi.tsjData.service.IDataTshjZhdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提升机-制动测试Controller
 * 
 * @author ruoyi
 * @date 2023-10-25
 */
@RestController
@RequestMapping("/tsjData/zhd")
@Api(value="提升机-制动测试",tags = "提升机-制动测试接口")
public class DataTshjZhdController extends BaseController
{
    @Autowired
    private IDataTshjZhdService dataTshjZhdService;

    /**
     * 查询提升机-制动测试列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhd:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataTshjZhd dataTshjZhd)
    {
        startPage();
        List<DataTshjZhd> list = dataTshjZhdService.selectDataTshjZhdList(dataTshjZhd);
        return getDataTable(list);
    }

    /**
     * 导出提升机-制动测试列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhd:export')")
    @Log(title = "提升机-制动测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataTshjZhd dataTshjZhd)
    {
        List<DataTshjZhd> list = dataTshjZhdService.selectDataTshjZhdList(dataTshjZhd);
        ExcelUtil<DataTshjZhd> util = new ExcelUtil<DataTshjZhd>(DataTshjZhd.class);
        util.exportExcel(response, list, "提升机-制动测试数据");
    }

    /**
     * 获取提升机-制动测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhd:query')")
    @GetMapping(value = "/{zhdId}")
    public AjaxResult getInfo(@PathVariable("zhdId") Long zhdId)
    {
        return success(dataTshjZhdService.selectDataTshjZhdByZhdId(zhdId));
    }

    /**
     * 新增提升机-制动测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhd:add')")
    @Log(title = "提升机-制动测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataTshjZhd dataTshjZhd)
    {
        return toAjax(dataTshjZhdService.insertDataTshjZhd(dataTshjZhd));
    }

    /**
     * 修改提升机-制动测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhd:edit')")
    @Log(title = "提升机-制动测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataTshjZhd dataTshjZhd)
    {
        return toAjax(dataTshjZhdService.updateDataTshjZhd(dataTshjZhd));
    }

    /**
     * 根据id和任务id变更数据状态
     */
    @ApiOperation(value="根据id和任务id变更数据状态")
    @PreAuthorize("@ss.hasPermi('tsjData:zhd:editByIdAndDataId')")
    @PostMapping("/editByIdAndDataId/{dataTaskId}/{zhdId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long"),
            @ApiImplicitParam(paramType="query", name = "zhdId", value = "制动id", required = true, dataType = "Long"),
    })
    public AjaxResult editByIdAndDataId(@PathVariable("dataTaskId")Long dataTaskId, @PathVariable("zhdId") Long zhdId) {
        return toAjax(dataTshjZhdService.updateDataTshjZhdByZhId(dataTaskId, zhdId));
    }

    /**
     * 修改生成提升机制动测试数据图
     */
    @ApiOperation(value="修改生成提升机制动测试数据图")
    @PreAuthorize("@ss.hasPermi('tsjData:zhd:editByCharts')")
    @PostMapping("/modifyChart")
    public AjaxResult modifyChart(@RequestBody DataTshjZhd dataTshjZhd) {
        return AjaxResult.success(dataTshjZhdService.modifyChart(dataTshjZhd.getCharts(), dataTshjZhd.getCsfsh()));
    }

    /**
     * 删除提升机-制动测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:zhd:remove')")
    @Log(title = "提升机-制动测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zhdIds}")
    @ApiOperation(value="删除提升机-制动测试")
    public AjaxResult remove(@PathVariable Long[] zhdIds)
    {
        return toAjax(dataTshjZhdService.deleteDataTshjZhdByZhdIds(zhdIds));
    }
}
